//
//  LaunchVC.m
//  gwyTest
//
//  Created by Steven on 2019/7/25.
//  Copyright © 2019 Steven. All rights reserved.
//

#import "LaunchVC.h"
#import "HttpTool.h"
#import "ZYNetworkAccessibity.h"
#import "AppDelegate.h"
@interface LaunchVC ()

@end

@implementation LaunchVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkChanged:) name:ZYNetworkAccessibityChangedNotification object:nil];
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    
    NSString *dateStr = @"2019-08-07";
    
    if ([[formatter stringFromDate:[NSDate new]] isEqualToString:dateStr]) {
        
        [HttpTool requestAD];
    }else{
        
        ((AppDelegate *)[UIApplication sharedApplication].delegate).window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"main"];
    }
    
//    [HttpTool requestAD];
}

- (void)networkChanged:(NSNotification *)notification {
    ZYNetworkAccessibleState state = ZYNetworkAccessibity.currentState;
    
    if (state == ZYNetworkRestricted) {
        NSLog(@"网络权限被关闭");
    }else{
        [HttpTool requestAD];
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
